<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace com\vip\vlp\service\vop\product;

class DetailGoods {
	
	static $_TSPEC;
	public $goods_id = null;
	public $product_name = null;
	public $sort = null;
	public $short_video_url = null;
	public $props = null;
	public $preview_images = null;
	public $detail_images = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'goods_id'
			),
			2 => array(
			'var' => 'product_name'
			),
			3 => array(
			'var' => 'sort'
			),
			4 => array(
			'var' => 'short_video_url'
			),
			5 => array(
			'var' => 'props'
			),
			6 => array(
			'var' => 'preview_images'
			),
			7 => array(
			'var' => 'detail_images'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['goods_id'])){
				
				$this->goods_id = $vals['goods_id'];
			}
			
			
			if (isset($vals['product_name'])){
				
				$this->product_name = $vals['product_name'];
			}
			
			
			if (isset($vals['sort'])){
				
				$this->sort = $vals['sort'];
			}
			
			
			if (isset($vals['short_video_url'])){
				
				$this->short_video_url = $vals['short_video_url'];
			}
			
			
			if (isset($vals['props'])){
				
				$this->props = $vals['props'];
			}
			
			
			if (isset($vals['preview_images'])){
				
				$this->preview_images = $vals['preview_images'];
			}
			
			
			if (isset($vals['detail_images'])){
				
				$this->detail_images = $vals['detail_images'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'DetailGoods';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("goods_id" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->goods_id);
				
			}
			
			
			
			
			if ("product_name" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->product_name);
				
			}
			
			
			
			
			if ("sort" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->sort); 
				
			}
			
			
			
			
			if ("short_video_url" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->short_video_url);
				
			}
			
			
			
			
			if ("props" == $schemeField){
				
				$needSkip = false;
				
				$this->props = array();
				$_size0 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem0 = null;
						
						$elem0 = new \com\vip\vlp\service\vop\product\DetailGoodsProps();
						$elem0->read($input);
						
						$this->props[$_size0++] = $elem0;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			
			if ("preview_images" == $schemeField){
				
				$needSkip = false;
				
				$this->preview_images = array();
				$_size1 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem1 = null;
						
						$elem1 = new \com\vip\vlp\service\vop\product\DetailImages();
						$elem1->read($input);
						
						$this->preview_images[$_size1++] = $elem1;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			
			if ("detail_images" == $schemeField){
				
				$needSkip = false;
				
				$this->detail_images = array();
				$_size2 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem2 = null;
						
						$elem2 = new \com\vip\vlp\service\vop\product\DetailImages();
						$elem2->read($input);
						
						$this->detail_images[$_size2++] = $elem2;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		$xfer += $output->writeFieldBegin('goods_id');
		$xfer += $output->writeString($this->goods_id);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('product_name');
		$xfer += $output->writeString($this->product_name);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('sort');
		$xfer += $output->writeI32($this->sort);
		
		$xfer += $output->writeFieldEnd();
		
		if($this->short_video_url !== null) {
			
			$xfer += $output->writeFieldBegin('short_video_url');
			$xfer += $output->writeString($this->short_video_url);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->props !== null) {
			
			$xfer += $output->writeFieldBegin('props');
			
			if (!is_array($this->props)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->props as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->preview_images !== null) {
			
			$xfer += $output->writeFieldBegin('preview_images');
			
			if (!is_array($this->preview_images)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->preview_images as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->detail_images !== null) {
			
			$xfer += $output->writeFieldBegin('detail_images');
			
			if (!is_array($this->detail_images)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->detail_images as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>